package com.ykg.controller;

import com.ykg.annotation.PassToken;
import com.ykg.dto.CUserDTO;
import com.ykg.enums.ResultEnum;
import com.ykg.service.ICuserService;
import com.ykg.util.ResultResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

/**
 *
 * 类(接口)：其他用户登录接口
 * Created on 15:56 2021/6/23.
 *
 * @Author: laobian
 * @Description:
 */
@Api(tags = "其他用户登录Api")
@RestController
@RequestMapping("/api/company")
public class CuserController {
    @Autowired
    private ICuserService cuserService;

    @PostMapping(value = "/login")
    @ApiOperation("其他用户登录")
    @PassToken
    public ResultResponse login(@RequestParam String cname,@RequestParam String password){
        if(cname==null || password==null){
            return new ResultResponse(ResultEnum.LOGIN_ERROR);
        }
        CUserDTO CUserDTO = cuserService.login(cname,password);
        if(Objects.isNull(CUserDTO)){
            return new ResultResponse(ResultEnum.LOGIN_ERROR);
        }

        return new ResultResponse(CUserDTO);
    }


}
